package com.example.yuan0603;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;

import androidx.appcompat.app.AppCompatActivity;

import com.example.yml.R;


public class IntentServiceActivity extends AppCompatActivity implements View.OnClickListener {

    private Button bt1;
    private Button bt2;
    Intent intent;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_intent_service);
        initView();
    }

    private void initView() {
        intent = new Intent(IntentServiceActivity.this, MyIntentService.class);

        bt1 = (Button) findViewById(R.id.bt1);
        bt2 = (Button) findViewById(R.id.bt2);

        bt1.setOnClickListener(this);
        bt2.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.bt1:
                startService(intent);
                break;
            case R.id.bt2:

                break;
        }
    }
}
